package com.newly.common.base.constants;

import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * @program: newly-parent
 * @remark: 菜单配置类
 * @author: guan
 * @create: 2021-12-28 17:24
 */
public interface MenuConstant {
    /**
     * 菜单模板名称
     */
    String MENU_TEMPLATE_FILE_NAME = "menuTemplate.xml";
    /**
     * 父菜单标识
     */
    int MENU_PARENT_FLAG = 0;
    /**
     * 默认的客户端uri(路由uri)
     */
    String[] DEFAULT_CLIENT_URI = {"", "/"};

    /**
     * 菜单能力
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    enum Ability {
        DIR(11, "dir", "目录"),
        MENU(12, "menu", "菜单"),
        SYS(10, "sys", "系统"),
        ADD(19, "add", "添加"),
        DEL(13, "del", "删除"),
        QUE(9, "que", "查询"),
        UPD(21, "upd", "修改"),
        EXP(18, "exp", "导出"),
        IMP(28, "imp", "导入");


        Ability(int code, String name, String remark) {
            this.code = code;
            this.name = name;
            this.remark = remark;
        }

        public static Ability getInstance(int code) {
            for (Ability value : Ability.values()) {
                if (value.getCode() == code) {
                    return value;
                }
            }
            return null;
        }

        private int code;
        private String name;
        private String remark;
        private boolean flag;

        public int getCode() {
            return code;
        }

        public String getRemark() {
            return remark;
        }

        public boolean isFlag() {
            return flag;
        }

        public void setFlag(boolean flag) {
            this.flag = flag;
        }

        public String getName() {
            return name;
        }
    }

    /**
     * 菜单类型
     */
    enum Type {
        SYS(1, "系统"),
        DIR(2, "目录"),
        MENU(3, "菜单"),
        BTN(4, "按钮");

        Type(int code, String remark) {
            this.code = code;
            this.remark = remark;
        }

        private int code;
        private String remark;

        public int getCode() {
            return code;
        }

        public String getRemark() {
            return remark;
        }
    }

    /**
     * 菜单类型
     */
    enum Enable {
        OPEN(1, "开启"),
        CLOSE(0, "关闭");

        Enable(int code, String remark) {
            this.code = code;
            this.remark = remark;
        }

        private int code;
        private String remark;

        public static Enable getInstance(Integer enable) {
            for (Enable value : Enable.values()) {
                if (enable.equals(value.getCode())) {
                    return value;
                }
            }
            return null;
        }

        public int getCode() {
            return code;
        }

        public String getRemark() {
            return remark;
        }
    }

    /**
     * 菜单类型
     */
    enum Access {
        OPEN(1, "开启"),
        CLOSE(0, "关闭");

        Access(int code, String remark) {
            this.code = code;
            this.remark = remark;
        }

        private int code;
        private String remark;

        public static Access getInstance(Integer access) {
            for (Access value : Access.values()) {
                if (access.equals(value.getCode())) {
                    return value;
                }
            }
            return null;
        }

        public int getCode() {
            return code;
        }

        public String getRemark() {
            return remark;
        }
    }
}
